package com.king.event;

import atlantafx.base.controls.Message;
import atlantafx.base.theme.Styles;
import javafx.geometry.Pos;
import javafx.scene.layout.StackPane;
import lombok.Getter;

/**
 * 通知-事件
 * 
 * @author king
 * @date 2025年7月16日-11:15:16
 */
@Getter
public class NotificationEvent extends Message {

	/**
	 * 动画过度时长，单位：秒
	 */
	private float duration;

	/**
	 * 是否自动关闭
	 */
	private boolean autoClose;

	public NotificationEvent(String msg, double width, float duration, String... styles) {
		super("通知", msg);
		// 这里我定义了，非自动关闭的
		this.autoClose = false;
		this.setMaxWidth(width);
		this.duration = duration;
		this.getStyleClass().addAll(Styles.ELEVATED_1);
		this.getStyleClass().addAll(styles);
		StackPane.setAlignment(this, Pos.TOP_RIGHT);
	}

	public NotificationEvent duration(float duration) {
		this.duration = duration;
		return this;
	}

	public NotificationEvent styles(String... styles) {
		this.getStyleClass().addAll(styles);
		return this;
	}

	public NotificationEvent autoClose(boolean autoClose) {
		this.autoClose = autoClose;
		return this;
	}

	public NotificationEvent(String msg, double width, float duration) {
		this(msg, width, duration, Styles.ACCENT);
	}

	public NotificationEvent(String msg, double width) {
		this(msg, width, 1f);
	}

	public NotificationEvent(String msg) {
		this(msg, 400);
	}

	/**
	 * 常用的工具方法
	 * 
	 * @param msg
	 * @return
	 * @author king
	 * @date 2025年7月16日-11:44:27
	 */
	public static NotificationEvent build(String msg) {
		return new NotificationEvent(msg);
	}

	public static NotificationEvent build(String msg, double width) {
		return new NotificationEvent(msg, width);
	}

	public static NotificationEvent build(String msg, float duration) {
		return new NotificationEvent(msg).duration(duration);
	}

}
